<template>
  <div>
    <h1 ><div style="color: red" >{{shop.name}}激活成功</div>
    <div>请等待{{count}}秒后自动跳转</div>
    <div>如果未自动跳转,请点击下方链接进行跳转</div>
    <div><a href="http://localhost:8081/#/login">点我跳转</a></div></h1></div>
</template>

<script>

export default {

  data() {
    return {
      str: '',
      id: null,
      shopId: 0,
      shop: {
        name: '',
      },
      count:''
    }
  },
  created() {
    this.countDown() // 倒计时
  },
  methods: {
    //几秒后进入跳转页面
    countDown() {
      const TIME_COUNT = 3
      if (!this.timer) {
        this.count = TIME_COUNT
        this.timer = setInterval(() => {
          if (this.count > 1 && this.count <= TIME_COUNT) { //限制倒计时区间
            this.count--
          } else {
            clearInterval(this.timer)   //删除定时器
            this.timer = null
            //跳转的页面写在此处
            this.$router.push("/login");
          }
        }, 1000)
      }
    },
    goActive() {
    this.str=window.location.href ;
    this.id = this.str.split("=");
    this.shopId=this.id[1]
      this.$http.get("/shop/active/"+this.shopId).then(result => {
        this.shop = result.data;
      }).catch(result=>{
        result.data.message("服务器繁忙,请稍后再试");
      });
    },
  },
  mounted() {
    this.goActive();
  }
}

</script>

<style scoped>

</style>